import { ref, computed } from "vue";
import { defineStore } from "pinia";

interface InfoType {
  name: string;
  token: string;
  checkedkeys: string;
}

export const useHomeStore = defineStore("home", () => {
  const isCollapse = ref<boolean>(false);

  const adminname = ref<string | null>(localStorage.getItem("adminname"));
  const token = ref<string | null>(localStorage.getItem("token"));
  const checkedkeys = ref<string | null>(localStorage.getItem("checkedkeys"));

  const changeLoginInfo = (info: InfoType) => {
    adminname.value = info.name;
    token.value = info.token;
    checkedkeys.value = info.checkedkeys;
  };

  return { isCollapse, adminname, token, changeLoginInfo, checkedkeys };
});
